package LeetCode;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName interview
 * @Description: TODO
 * @date ${DAT}8:31
 */
public class leetCode100II {
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode(int x) { val = x; }
    }


    public boolean isSameTree(TreeNode p, TreeNode q) {
        //终止条件
        if (p == null && q == null){
            return true;
        }
        if (p == null || q == null){
            return false;
        }

        if (p.val == q.val){
            return isSameTree(p.right,q.right) && isSameTree(p.left,q.left);
        }
        return false;
    }
}
